-
-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify the result of decoding (QR, Datamatrix, AZTEC and MaxiCode) as byte[] #442
base: master
Are you sure you want to change the base?
Conversation
…with the content readed before being submited to a specific encoding
…) for QR and Datamatrix -> corrected ADD-HOC solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally find some time to make a first review. Feel free to discuss my comments.
@@ -77,6 +77,8 @@ internal static DecoderResult decode(byte[] bytes, int mode) | |||
} | |||
String country = getCountry(bytes).ToString(THREE_DIGITS); | |||
String service = getServiceClass(bytes).ToString(THREE_DIGITS); | |||
|
|||
var msg = getMessage(bytes, 10, 84); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should not be necessary, I think
@@ -95,7 +97,7 @@ internal static DecoderResult decode(byte[] bytes, int mode) | |||
break; | |||
} | |||
|
|||
return new DecoderResult(bytes, result.ToString(), null, mode.ToString()); | |||
return new DecoderResult(bytes, Encoding.UTF8.GetBytes(result.ToString()), result.ToString(), null, mode.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, that default behavior (UTF8.GetBytes(...)) should better be placed in the Result class because it would be cleaner to see what class really gives the byte data (like the qr code implementation).
@@ -66,7 +66,7 @@ public Result decode(BinaryBitmap image, IDictionary<DecodeHintType, object> hin | |||
if (decoderResult == null) | |||
return null; | |||
|
|||
var result = new Result(decoderResult.Text, decoderResult.RawBytes, NO_POINTS, BarcodeFormat.MAXICODE); | |||
var result = new Result(decoderResult.Text, decoderResult.Data, decoderResult.RawBytes, NO_POINTS, BarcodeFormat.MAXICODE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be reverted, see the comment at DecodedBitStreamParser.cs; Result class can generate the value of Data property if the reader doesn't give a better value.
{ | ||
if (text == null && rawBytes == null) | ||
{ | ||
throw new ArgumentException("Text and bytes are null"); | ||
} | ||
Text = text; | ||
Data = data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be a good place to add the default behavior UTF8.GetBytes(text) if data == null
Hello, I'm using ZXing.Net.Mobile.Forms, which in turn uses ZXing.Net in a specific Xamarin.Forms mobile project. So I'm absolutely not an expert in the process of barcode decoding. In short, that project scans a barcode that contains some data. However, this data has not 'string' specific format, so we, in fact, want the data as binary. Now we are only using 2 implementations of barcode: Datamatrix and QR. Datamatrix, no problem, we were getting the data by encode the string with ISO-8859-1 and no problem, we could get it. Nevertheless, with QR, that's not the same. When we tried to encode this string with ISO-8859-1 we had lose a lot of information (some characters were mapped to 3f == '?'). So we propose this little alteration, in order to return the text result along with the binary information used to achieve it when applying a specific encoding.